<?php
namespace app\common\lib\exception;
use think\Exception;
use think\exception\Handle;
/**
 * Class ApiHandel
 * API 异常抛出
 */
class ApiHandel extends Handle
{
    public $httpCode = 500;
    /**
     * @param Exception $e
     * @return \think\Response|void
     */
    public function render(\Exception $e){
        if (config('app_debug') == true){
            // 调试模式
            return parent::render($e);
        }
        if ($e instanceof ApiException) {
            return apiReturn($e->code, $e->getMessage(), [], $e->httpCode);
        }
    }
}